{% extends 'mysite/base.html' %}
{% load staticfiles %}
{% block header %}
    <link rel="stylesheet" href="{% static 'tinymce/plugins/upload/plugin.css' %}">
    <script type="text/javascript" src="{% static 'tinymce/tinymce.min.js' %}"></script>
    <script type="text/javascript">
        tinymce.init({
            selector: "textarea",
            //width: 800,
            height: 300,
            forced_root_block: false,
            plugins: [
                "advlist autolink lists link image charmap print preview anchor sh4tinymce upload",
                "searchreplace visualblocks code fullscreen",
                "insertdatetime table contextmenu paste addmore"
            ],
            upload_action: 'upload.php',   //required
            upload_file_name: 'userfile',  //required
            toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter" +
            " alignright alignjustify | bullist numlist outdent indent | preview link image upload sh4tinymce"
        });
    </script>
{% endblock %}
{% block content %}
    <div class="post">
        <h2>{% if is_new %}新建文章{% else %}编辑文章{% endif %}</h2>
        <form method="POST" class="post-form">{% csrf_token %}
            <div class="content">
                <p>{{ form.as_p }}</p>
                <p>
                    <label for="tag">标签(逗号隔开)：</label>
                    <input id="tag" name="tags" type="text" class="form-control"
                           placeholder="tags" style="width: 60%;" value="{{ tags }}" />
                </p>
                <button type="button" class="save btn btn-default" onclick="location.href='/'">取消</button>
                <button type="submit" class="save btn btn-default" style="margin-right: 5px;">保存</button>
            </div>
        </form>
    </div>
{% endblock %}
